<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <ui:composition template="/view/template.xhtml">
        <ui:define name="head">
            <script type="text/javascript">
                    function handleSaveRequest(xhr, status, args) {
                            if(args.success) {
                                    commodityDialog.hide();
                            } else if(args.duplicate ){
                                     commodityDialog.hide();
                            }
                    }
            </script>
        </ui:define>
        <ui:define  name="content">
            <f:view>
                <h:form id ="form1">
                    <p:dataTable value="#{commodityManager.commodityList}"  var="item" id="commodities" paginator="true" rows="20" paginatorPosition="bottom">
                        <f:facet name="header">
                            <h:panelGrid columns="2" cellpadding="0" cellspacing="0">
                                <p:breadCrumb preview="true" expandEffectDuration="200" previewWidth="20" style="width:400px" expandedBeginningItems="1" expandedEndItems="0">
                                    <p:menuitem value="选项"/>
                                    <p:menuitem value="查询库存不足商品" actionListener="#{commodityManager.searchInadequateCommodities}" update="form1:commodities"/>
                                </p:breadCrumb>
                                <h:panelGrid columns="6" style="width: 500px">
                                    <h:outputLabel value="模糊查询"></h:outputLabel>
                                    <h:inputText value="#{commodityManager.searchContent}" title="可输入部分商品与名称进行查询"></h:inputText>
                                    <p:commandLink update="form1:commodities" actionListener="#{commodityManager.seachByContent}">
                                        <p:graphicImage value="/resources/images/search.png"/>
                                    </p:commandLink>
                                    <p:ajaxStatus  style="width:16px;height:16px;">
                                        <f:facet name="start">
                                            <h:graphicImage  value="/resources/images/ajaxloading.gif" />
                                        </f:facet>
                                        <f:facet name="complete">
                                            <h:outputText value=""/>
                                        </f:facet>
                                    </p:ajaxStatus>
                                    <h:selectOneMenu value="#{commodityManager.commodityProperty}">
                                        <f:selectItems value="#{applicationBean.retailMaterialCommodityPropertyItems}"/>
                                        <p:ajax  update="form1:commodities,form1:commodityTypes" listener="#{commodityManager.searchByProperty}" />
                                    </h:selectOneMenu>
                                    <h:selectOneMenu id="commodityTypes" value="#{commodityManager.commodityType}">

                                        <f:selectItems value="#{commodityManager.commodityTypeItems}"></f:selectItems>
                                        <p:ajax  update="form1:commodities" listener="#{commodityManager.searchByType}" />
                                    </h:selectOneMenu>
                                </h:panelGrid>
                            </h:panelGrid>
                        </f:facet>

                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="属性"/>
                            </f:facet>
                            <h:outputText value="#{item.property}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="名称"/>
                            </f:facet>
                            <h:outputText value="#{item.name}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="编码"/>
                            </f:facet>
                            <h:outputText value="#{item.number}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="库存"/>
                            </f:facet>
                            <h:outputText value="#{item.stocks}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="单位"/>
                            </f:facet>
                            <h:outputText value="#{item.unit}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="类型"/>
                            </f:facet>
                            <h:outputText value="#{item.type}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="单价"/>
                            </f:facet>
                            <h:outputText value="#{item.uitPrice}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="成本"/>
                            </f:facet>
                            <h:outputText value="#{item.unitCost}"/>
                        </p:column>
                      
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="启用"/>
                            </f:facet>
                            <h:selectBooleanCheckbox disabled="true" value="#{item.active}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="可否打折"/>
                            </f:facet>
                            <h:selectBooleanCheckbox disabled="true" value="#{item.discountable}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="需求"/>
                            </f:facet>
                            <h:outputText value="#{item.quantityRequired}"/>
                        </p:column>
                    </p:dataTable>
                </h:form>
            </f:view>
        </ui:define>
    </ui:composition>
</html>
